package com.lzx.demo.work2;

/**
 * @author 程序员星星
 * @date 2023/3/23
 * @Description
 */
public class Demo2 {
    public static void main(String[] args) {
        int n = 1000; // 最大值
        for (int i = 1; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                int sum = 0;
                for (int k = i; k <= j; k++) {
                    sum += k * k * k;
                }
                int cubeRoot = (int) Math.round(Math.pow(sum, 1.0 / 3.0));
                if (cubeRoot * cubeRoot * cubeRoot == sum) {
                    System.out.println("相邻的整数 " + i + " 到 " + j + " 的立方和是 " + sum);
                }
            }
        }
    }
}
